<?xml version='1.0' encoding='UTF-8' ?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:c="http://java.sun.com/jsp/jstl/core">
    <!--Inicia la composicion de la pagina en la plantilla-->
    <ui:composition template="/resource/template/plantilla.xhtml">
        <!--Segmento que define el contenido del header-->
        <ui:define name="head">
            <h:head>
                <f:loadBundle basename="request.general.label_es" var="label" />
                <f:loadBundle basename="request.general.message_es" var="message" />
                <script type="text/javascript" src="../../../resource/js/jquery.fancybox.js" />
                <link rel="stylesheet" type="text/css" href="../../../resource/css/fancybox.css" />
                <script>
                    $(document).ready(function() {
                        $(".formulario").fancybox({
                            type: 'ajax'
                        });
                    });
                    $(function() {
                        $("#form1\\:universidad").mousedown(function() {
                            $("#form1\\:facultad").val(0);
                            $("#form1\\:accion").val(0);
                            $("#form1\\:carrera").val("");
                            $("#form1\\:observacion").val("");
                        });
                    });
                    $(function() {
                        $("#form1\\:facultad").mousedown(function() {
                            $("#form1\\:accion").val(0);
                            $("#form1\\:carrera").val("");
                            $("#form1\\:observacion").val("");
                        });
                    });
                </script>
                <script>
                    function verificar(dato)
                    {
                        var agree = confirm(dato);
                        if (agree)
                            return true;
                        else
                            return false;
                    }
                </script>
            </h:head>
        </ui:define>

        <!--Segmento que define el contenido de la pagina-->
        <ui:define name="content">
            <h:body>
                <h:outputText value="#{message.m0}" class="label" rendered="#{!access.visit}"/>
                <h:form rendered="#{access.visit}"> 
                    <p:growl id="messages" showDetail="true"/>
                    <div class="field">
                        <h:outputText value="#{label.field4}" class="label"/>
                        <h:inputText id="carrera" value="#{request_general.carrera}"
                                     required="true" requiredMessage="#{message.m25}" class="textfield" size="50" />
                        <h:outputText class="required" value="*"/>
                    </div>
                    <div class="field">
                        <h:outputText value="#{label.field1}" class="label"/>
                        <h:selectOneMenu id="universidad" class="select" value="#{request_general.universityBeans.id}" onchange="submit()" >
                            <f:selectItem itemLabel="" itemValue=""/>
                            <f:selectItems value="#{university_generalFind.listItem()}"/>  
                        </h:selectOneMenu>
                        <h:commandButton id="btnUniversidad" class="addButton" onclick="addUniversidad.show();" type="button"/>
                        <h:outputText class="required" value="*"/>
                    </div>
                    <div class="field">
                        <h:outputText value="#{label.field2}" class="label"/>
                        <h:selectOneMenu id="facultad" class="select" value="#{request_general.id_facultad}" onchange="submit()">
                            <f:selectItem itemLabel="" itemValue=""/>
                            <f:selectItem itemLabel="" itemValue=""/>
                            <f:selectItems value="#{university_facultyFind.listItem(request_general.universityBeans.id)}"/> 
                        </h:selectOneMenu>
                        <h:commandButton id="btnFaculty" class="addButton" onclick="addFaculty.show();" type="button"/>
                        <h:outputText class="required" value="*"/>
                    </div>
                    <div class="field">
                        <h:outputText value="#{label.field3}" class="label"/>
                        <h:selectOneMenu id="accion" class="select" value="#{request_general.idl_accion}">  
                            <f:selectItem itemLabel="" itemValue="0"/>
                            <f:selectItem itemLabel="#{label.accion1}" itemValue="1"/> 
                            <f:selectItem itemLabel="#{label.accion2}" itemValue="2"/> 
                            <f:selectItem itemLabel="#{label.accion3}" itemValue="3"/> 
                            <f:selectItem itemLabel="#{label.accion4}" itemValue="4"/>
                        </h:selectOneMenu>   
                        <h:outputText class="required" value="*"/>
                    </div>
                    <div class="field">
                        <h:outputText value="#{label.field6}" class="label"/>
                        <p:calendar value="#{request_general.recibido}" effect="slide" navigator="true" readonlyInput="true" pattern="dd/MM/yy" yearRange="c-82:c+10" size="5"/>
                    </div>

                    <div class="field">
                        <h:outputText value="#{label.field5}" class="label"/>
                        <h:inputTextarea id="observacion" class="textArea" value="#{request_general.observacion}" rows="2" />  
                    </div>
                    <!--INSERTAR-->
                    <h:commandButton class="button" value="#{label.button1}" action="#{request_general.insert}" rendered="#{access.add}" onclick="return verificar('#{message.m7}')"/>
                    <!--ACTUALIZAR-->
                    <h:commandButton class="button" value="#{label.button2}" action="#{request_general.update}" rendered="#{access.update}" onclick="return verificar('#{message.m8}')"/>
                    <!--ELIMINAR-->
                    <h:commandButton class="button" value="#{label.button3}" action="#{request_general.delete}" rendered="#{access.delete}" onclick="return verificar('#{message.m9}')"/>
                    <!--LIMPIAR-->
                    <h:commandButton class="button" value="#{label.button4}" action="#{request_general.clear}" rendered="#{access.visit}"/>
                    <!--FORMULARIO-->
                    <h:outputLink class="formulario" value="../../request/detail/main.xhtml" rendered="#{logged.masterId ne 0}">  
                        <h:commandButton value="#{label.button5}" class="button" rendered="#{logged.masterId ne 0}"/>
                    </h:outputLink>
                    <!--REPORTE-->
                    <h:commandLink target="_blank" actionListener="#{request_generalReport.curriculum}">
                        <h:commandButton class="button"  value="#{label.button6}" />
                    </h:commandLink>

                    <p:dialog id="addUniversidad" widgetVar="addUniversidad" header="#{label.title2}" modal="true" resizable="false">
                        <h:panelGrid>
                            <div class="field">
                                <h:outputText value="#{label.field9}" class="label"/>
                                <h:inputText value="#{request_general.universityBeans.nombre}" class="textfield"/>
                            </div>

                            <div class="field">
                                <h:outputText value="#{label.field10}" class="label"/>
                                <h:inputText value="#{request_general.universityBeans.fundada}" size="4" maxlength="4" class="textfield"/>
                            </div>

                            <div class="field">
                                <h:outputText value="#{label.field11}" class="label"/>
                                <h:inputTextarea value="#{request_general.universityBeans.detalle}" class="textfield"/>
                            </div>
                            <h:commandButton value="#{label.button1}" class="button" actionListener="#{request_general.insertUniversity}" onclick="addUniversidad.hide();"/>
                        </h:panelGrid>
                    </p:dialog>

                    <p:dialog id="addFaculty" widgetVar="addFaculty" header="#{label.title3}" modal="true" resizable="false">
                        <h:panelGrid>
                            <div class="field">
                                <h:outputText value="#{label.field9}" class="label"/>
                                <h:inputText value="#{request_general.facultyBeans.nombre}" class="textfield"/>
                            </div>
                            <h:commandButton value="#{label.button1}" class="button" actionListener="#{request_general.insertFaculty()}" onclick="addUniversidad.hide();"/>
                        </h:panelGrid>
                    </p:dialog>
                </h:form>

            </h:body>
        </ui:define>

        <!--Segemento donde se define un texto de ayuda para que el usuario pueda utilizar el formulario del contenido-->
        <ui:define name="slideHelper">

        </ui:define>
    </ui:composition>

</html>
